/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.pras.skripsi;

/**
 *
 * @author Pras
 */
public class getResult {

    String result = "";
    int[] k = new int[4];

    public String getResult() {
        int angka1 = (Integer) Result.getHasilAngka()[0][0];
        int angka2 = (Integer) Result.getHasilAngka()[1][0];



        if (Result.getHasilAngka()[0][1].equals((String) Result.getKunci()[angka1])
                && Result.getHasilAngka()[1][1].equals((String) Result.getKunci()[angka2])) {

            if (Result.getHasilBentuk()[0][1] == ImageFactory.getOption()[0][0]
                    && Result.getHasilBentuk()[1][1] == ImageFactory.getOption()[1][0]) {
                result = "Normal";
            } else if (Result.getHasilBentuk()[0][1] == ImageFactory.getOption()[0][2]
                    && Result.getHasilBentuk()[1][1] == ImageFactory.getOption()[1][2]) {
                result = "Deuteronopia / Deuteronomalia Parah";
            } else if (Result.getHasilBentuk()[0][1] == ImageFactory.getOption()[0][4]
                    && Result.getHasilBentuk()[1][1] == ImageFactory.getOption()[1][4]) {
                result = "Protonopia / Protonomalia Parah";
            } else if (Result.getHasilBentuk()[0][1] == ImageFactory.getOption()[0][1]
                    || Result.getHasilBentuk()[1][1] == ImageFactory.getOption()[1][1]) {
                result = "Deuteronomalia Ringan";
            } else if (Result.getHasilBentuk()[0][1] == ImageFactory.getOption()[0][3]
                    || Result.getHasilBentuk()[1][1] == ImageFactory.getOption()[1][3]) {
                result = "Protonomalia Ringan";
            } else if (Result.getHasilBentuk()[0][1] == ImageFactory.getOption()[0][5]
                    || Result.getHasilBentuk()[1][1] == ImageFactory.getOption()[1][5]) {
                result = "Buta Warna Total";
            } 
        } else if (Result.getHasilAngka()[0][1].equals(String.valueOf(Result.getKunci()[angka1]).substring(0, 1))
                && Result.getHasilAngka()[1][1].equals(String.valueOf(Result.getKunci()[angka2]).substring(0, 1))) {
            result = "Deuteronopia / Deuteronomalia";
        } else if (Result.getHasilAngka()[0][1].equals(String.valueOf(Result.getKunci()[angka1]).substring(1, 2))
                && Result.getHasilAngka()[1][1].equals(String.valueOf(Result.getKunci()[angka2]).substring(1, 2))) {
            result = "Protonopia / Protonomalia";
        } else {
            if (Result.getHasilAngka()[0][1].equals((String) Result.getKunci()[angka1])) {
                k[0] += 1;
            } else {
                if (Result.getHasilAngka()[0][1].toString().length() == 2) {
                    if (Result.getHasilAngka()[0][1].toString().substring(1, 2).equals(String.valueOf(Result.getKunci()[angka1]).substring(1, 2))) {
                        k[2] += 1;
                    } else if (Result.getHasilAngka()[0][1].toString().substring(1, 2).equals(String.valueOf(Result.getKunci()[angka1]).substring(0, 1))) {
                        k[1] += 1;
                    } else if (Result.getHasilAngka()[0][1].toString().substring(0, 1).equals(String.valueOf(Result.getKunci()[angka1]).substring(1, 2))) {
                        k[2] += 1;
                    } else if (Result.getHasilAngka()[0][1].toString().substring(0, 1).equals(String.valueOf(Result.getKunci()[angka1]).substring(0, 1))) {
                        k[1] += 1;
                    } else {
                        k[3] += 1;
                    }
                } else {
                    if (Result.getHasilAngka()[0][1].toString().equals(String.valueOf(Result.getKunci()[angka1]).substring(1, 2))) {
                        k[2] += 1;
                    } else if (Result.getHasilAngka()[0][1].toString().equals(String.valueOf(Result.getKunci()[angka1]).substring(0, 1))) {
                        k[1] += 1;
                    } else {
                        k[3] += 1;
                    }
                }
            }

            if (Result.getHasilAngka()[1][1].equals((String) Result.getKunci()[angka2])) {
                k[0] += 1;
            } else {
                if (Result.getHasilAngka()[1][1].toString().length() == 2) {
                    if (Result.getHasilAngka()[1][1].toString().substring(1, 2).equals(String.valueOf(Result.getKunci()[angka2]).substring(1, 2))) {
                        k[2] += 1;
                    } else if (Result.getHasilAngka()[1][1].toString().substring(1, 2).equals(String.valueOf(Result.getKunci()[angka2]).substring(0, 1))) {
                        k[1] += 1;
                    } else if (Result.getHasilAngka()[1][1].toString().substring(0, 1).equals(String.valueOf(Result.getKunci()[angka2]).substring(1, 2))) {
                        k[2] += 1;
                    } else if (Result.getHasilAngka()[1][1].toString().substring(0, 1).equals(String.valueOf(Result.getKunci()[angka2]).substring(0, 1))) {
                        k[1] += 1;
                    } else {
                        k[3] += 1;
                    }
                } else {
                    if (Result.getHasilAngka()[1][1].toString().equals(String.valueOf(Result.getKunci()[angka2]).substring(1, 2))) {
                        k[2] += 1;
                    } else if (Result.getHasilAngka()[1][1].toString().equals(String.valueOf(Result.getKunci()[angka2]).substring(0, 1))) {
                        k[1] += 1;
                    } else {
                        k[3] += 1;
                    }
                }
            }

            if (Result.getHasilBentuk()[0][1] == ImageFactory.getOption()[0][0]) {
                k[0] += 1;
            } else {
                if (Result.getHasilBentuk()[0][1] == ImageFactory.getOption()[0][1]) {
                    k[1] += 1;
                } else if (Result.getHasilBentuk()[0][1] == ImageFactory.getOption()[0][2]) {
                    k[1] += 1;
                } else if (Result.getHasilBentuk()[0][1] == ImageFactory.getOption()[0][3]) {
                    k[2] += 1;
                } else if (Result.getHasilBentuk()[0][1] == ImageFactory.getOption()[0][4]) {
                    k[2] += 1;
                } else {
                    k[3] += 1;
                }
            }
            
            if (Result.getHasilBentuk()[1][1] == ImageFactory.getOption()[1][0]) {
                k[0] += 1;
            } else {
                if (Result.getHasilBentuk()[1][1] == ImageFactory.getOption()[1][1]) {
                    k[1] += 1;
                } else if (Result.getHasilBentuk()[1][1] == ImageFactory.getOption()[1][2]) {
                    k[1] += 1;
                } else if (Result.getHasilBentuk()[1][1] == ImageFactory.getOption()[1][3]) {
                    k[2] += 1;
                } else if (Result.getHasilBentuk()[1][1] == ImageFactory.getOption()[1][4]) {
                    k[2] += 1;
                } else {
                    k[3] += 1;
                }
            }
int a = 0;
            if (k[0] > k[1] && k[0] > k[2] && k[0] > k[3]) {
                result = "Normal";
            } else if (k[1] > k[0] && k[1] > k[2] && k[1] > k[3]) {
                result = "Deuteronomalia";
            } else if (k[2] > k[0] && k[2] > k[1] && k[2] > k[3]) {
                result = "Protanomalia";
            } else {
                result = "Buta Warna Total";
            }
        }

        return result;
    }
}
